package risk.control.project.config.tomcat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class TomcatConfig {
    private static final Logger logger = LoggerFactory.getLogger(TomcatConfig.class);

    @Bean(name = {"TomcatConfig"})
    public ServerProperties.Tomcat tomcatConfig() {
        logger.warn("=======>Tomcat初始化了<=======");
        //1核2g内存，线程数经验值200
        //4核8g内存，线程数经验值800
        ServerProperties.Tomcat tomcat = new ServerProperties.Tomcat();
        tomcat.setMaxConnections(1000);//最大连接数
        tomcat.setAcceptCount(400);//最大连接等待数
        ServerProperties.Tomcat.Threads threads = tomcat.getThreads();
        threads.setMax(400);//最大工作线程数
        threads.setMinSpare(100);//最小工作线程数
        return tomcat;
    }
}
